<template>
  <div class="tabList">
    <div
      class="flex col-center tabData"
      :class="{ 'WY': isWY }"
      v-for="item in HomeList"
      ref=""
      :key="item.name"
      @click="gto(item)"
    >
      <img :src="item.url" alt="" class="wh60 ml-40 mr-40" />
      <div class="HomeTitle font-20">
        {{ item.name }}
      </div>
    </div>
  </div>
</template>

<script setup>
import { ref, onMounted } from "vue";
import logoHome from "../../assets/image/home/newHome.png";
import homeJG from "../../assets/image/home/homeJG.png";
import logoZxiu from "../../assets/image/home/zxiu.png";
import { useRouter } from "vue-router";
import { useUserStore } from "@/stores/user.js";
const router = useRouter();
const store = useUserStore();
const isWY = ref(false)

const HomeList = ref([
  {
    name: "房屋信息",
    url: logoHome,
    route: "/homeList",
  },
  {
    name: "装修信息",
    url: logoZxiu,
    route: "/renovation",
  },
  {
    name: "出租信息",
    url: homeJG,
    route: "/rental",
  },
])

/**
 * 跳转
 */
const gto = (item) => {
  router.push(item.route);
}
onMounted(() => {
  // console.log('store.user', store.userInfo.roles[0].roleName)

  // 如果是物业人员
  if (store.userInfo.roles[0].roleName === "物业人员") {
    isWY.value = true
    HomeList.value = [
      {
        name: "房屋信息",
        url: logoHome,
        route: "/homeList",
      },{
        name: "装修服务",
        url: logoHome,
        route: "/decoration",
      },{
        name: "违规投诉",
        url: logoHome,
        route: "/violationComplaint",
      },{
        name: "房屋出租",
        url: logoHome,
        route: "/rental",
      }, {
        name: "租客信息",
        url: logoHome,
        route: "/rental",
      }
    ]
  }
})
</script>

<style lang="scss" scoped>
.tabList {
  padding: 15px;
  .tabData {
    border-radius: 10px;
    margin-top: 30px;
    background: #ffffff;
    padding: 15px;
    .wh60 {
      width: 60px;
      height: 60px;
    }
  }
  .WY:first-child {
    margin-top: 30px !important;
  }
  .WY {
    margin-top: 10px !important;
  }
  .WY:last-child {
    margin-bottom: 95px;
  }
  // .tabData:first-child {
  //   margin-top: 180px;
  // }
}
</style>
